import { request } from 'umi';
import {TargetType} from './data';
import {EchartsLineBarDataType} from "./data";

// 按年份获取基本数据
export async function queryDefaultData(
  params: {
    year?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: TargetType,
    success: boolean,
    status: string,
  }>('/api/analyse/totalData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 获取本周数据
export async function queryThisWeekData(
  options?: Record<string, any>,
) {
  return request<{
    data: EchartsLineBarDataType,
    success: boolean,
    status: string,
  }>('/api/analyse/thisWeekData', {
    method: 'GET',
    ...(options || {}),
  });
}

// 获取收入分类
// 年度收入
export async function queryIncomePieData(
  params: {
    year?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/incomePieData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 月度收入
export async function queryMonthIncomePieData(
  params: {
    month?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/monthIncomePieData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 年度支出
export async function queryPaymentPieData(
  params: {
    year?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/paymentPieData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 年度成员支出
export async function queryFamilyPaymentPieData(
  params: {
    year?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/familyPaymentPieData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 月度支出
export async function queryMonthPaymentPieData(
  params: {
    month?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/monthPaymentPieData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 月度成员支出
export async function queryMonthFamilyPaymentPieData(
  params: {
    month?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/monthFamilyPaymentPieData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 月度收入支出
export async function queryMonthPayAndIncomeData(
  params: {
    month?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/monthPayAndIncomeData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 年度收支
export async function queryYearPayAndIncomeData(
  params: {
    year?: string;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: any,
    success: boolean,
    status: string,
  }>('/api/analyse/yearPayAndIncomeData', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
